<template>
  <el-tag
    v-for="tag in dynamicTags"
    :key="tag"
    class="mx-1"
    closable
    :disable-transitions="false"
    @close="handleClose(tag)"
  >
    {{ tag.fileName }}
  </el-tag>
  <el-button class="button-new-tag ml-1" style="margin-left: 10px" size="small" @click="this.$refs.minioUpload2.selectFile()">+ 上传</el-button>
  <minio-upload ref="minioUpload2" @success="uploadCallback2"/>
</template>

<script lang="ts" setup>
import { nextTick, ref, defineProps } from 'vue'
import MinioUpload from "./Upload/MinioUpload.vue";

const props = defineProps({
  list: {
    type: Array, // 参数类型
    default: [], //默认值
    required: true //是否必传
  }
})
const emit = defineEmits(['success']);
const dynamicTags = ref([])

dynamicTags.value.push(...props.list);
const handleClose = (tag: string) => {
  dynamicTags.value.splice(dynamicTags.value.indexOf(tag), 1)
}

const uploadCallback2 = (fileInfo) => {
  if (fileInfo.url) {
    dynamicTags.value.push(fileInfo)
    emit('success', dynamicTags.value)
  } else {

  }
}
</script>
